<?php
/**
 * Created by PhpStorm.
 * User: kun
 * Date: 24/6/19
 * Time: 23:52
 */

namespace app\common\lib;


/**
 * 极光推送基础类库
 *
 */
class Jpush
{
    public static function push($title, $newId = 0, $type = 'all')
    {
        try {
            $client = new \JPush\Client(config('jpush.ak'), config('jpush.sk'));
            $client->push()
                ->setPlatform($type)
                ->addAllAudience()
                ->setNotificationAlert($title)
                ->androidNotification($title, array(
                    'title' => $title,
                    // 'builder_id' => 2,
                    'extras' => array(
                        'id' => $newId,
                    ),
                ))
                ->send();

        } catch (\Exception $e) {
//            echo $e->getMessage();
            return false;
        }

        return true;


    }


}